<?php


abstract class BasePosts extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $title;


	
	protected $position;


	
	protected $description;


	
	protected $author_id;


	
	protected $mincommitment;


	
	protected $basicsalary;


	
	protected $workfrom;


	
	protected $equity;


	
	protected $posttype;


	
	protected $url;


	
	protected $founders;


	
	protected $founded;


	
	protected $stage;


	
	protected $privatepost;


	
	protected $created_at;


	
	protected $updated_at;

	
	protected $aUser;

	
	protected $collPost2Twits;

	
	protected $lastPost2TwitCriteria = null;

	
	protected $collCommentss;

	
	protected $lastCommentsCriteria = null;

	
	protected $collTag2Posts;

	
	protected $lastTag2PostCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getTitle()
	{

		return $this->title;
	}

	
	public function getPosition()
	{

		return $this->position;
	}

	
	public function getDescription()
	{

		return $this->description;
	}

	
	public function getAuthorId()
	{

		return $this->author_id;
	}

	
	public function getMincommitment()
	{

		return $this->mincommitment;
	}

	
	public function getBasicsalary()
	{

		return $this->basicsalary;
	}

	
	public function getWorkfrom()
	{

		return $this->workfrom;
	}

	
	public function getEquity()
	{

		return $this->equity;
	}

	
	public function getPosttype()
	{

		return $this->posttype;
	}

	
	public function getUrl()
	{

		return $this->url;
	}

	
	public function getFounders()
	{

		return $this->founders;
	}

	
	public function getFounded()
	{

		return $this->founded;
	}

	
	public function getStage()
	{

		return $this->stage;
	}

	
	public function getPrivatepost()
	{

		return $this->privatepost;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getUpdatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->updated_at === null || $this->updated_at === '') {
			return null;
		} elseif (!is_int($this->updated_at)) {
						$ts = strtotime($this->updated_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
			}
		} else {
			$ts = $this->updated_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = PostsPeer::ID;
		}

	} 
	
	public function setTitle($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->title !== $v) {
			$this->title = $v;
			$this->modifiedColumns[] = PostsPeer::TITLE;
		}

	} 
	
	public function setPosition($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->position !== $v) {
			$this->position = $v;
			$this->modifiedColumns[] = PostsPeer::POSITION;
		}

	} 
	
	public function setDescription($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->description !== $v) {
			$this->description = $v;
			$this->modifiedColumns[] = PostsPeer::DESCRIPTION;
		}

	} 
	
	public function setAuthorId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->author_id !== $v) {
			$this->author_id = $v;
			$this->modifiedColumns[] = PostsPeer::AUTHOR_ID;
		}

		if ($this->aUser !== null && $this->aUser->getId() !== $v) {
			$this->aUser = null;
		}

	} 
	
	public function setMincommitment($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->mincommitment !== $v) {
			$this->mincommitment = $v;
			$this->modifiedColumns[] = PostsPeer::MINCOMMITMENT;
		}

	} 
	
	public function setBasicsalary($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->basicsalary !== $v) {
			$this->basicsalary = $v;
			$this->modifiedColumns[] = PostsPeer::BASICSALARY;
		}

	} 
	
	public function setWorkfrom($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->workfrom !== $v) {
			$this->workfrom = $v;
			$this->modifiedColumns[] = PostsPeer::WORKFROM;
		}

	} 
	
	public function setEquity($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->equity !== $v) {
			$this->equity = $v;
			$this->modifiedColumns[] = PostsPeer::EQUITY;
		}

	} 
	
	public function setPosttype($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->posttype !== $v) {
			$this->posttype = $v;
			$this->modifiedColumns[] = PostsPeer::POSTTYPE;
		}

	} 
	
	public function setUrl($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->url !== $v) {
			$this->url = $v;
			$this->modifiedColumns[] = PostsPeer::URL;
		}

	} 
	
	public function setFounders($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->founders !== $v) {
			$this->founders = $v;
			$this->modifiedColumns[] = PostsPeer::FOUNDERS;
		}

	} 
	
	public function setFounded($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->founded !== $v) {
			$this->founded = $v;
			$this->modifiedColumns[] = PostsPeer::FOUNDED;
		}

	} 
	
	public function setStage($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->stage !== $v) {
			$this->stage = $v;
			$this->modifiedColumns[] = PostsPeer::STAGE;
		}

	} 
	
	public function setPrivatepost($v)
	{

		if ($this->privatepost !== $v) {
			$this->privatepost = $v;
			$this->modifiedColumns[] = PostsPeer::PRIVATEPOST;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = PostsPeer::CREATED_AT;
		}

	} 
	
	public function setUpdatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->updated_at !== $ts) {
			$this->updated_at = $ts;
			$this->modifiedColumns[] = PostsPeer::UPDATED_AT;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->title = $rs->getString($startcol + 1);

			$this->position = $rs->getString($startcol + 2);

			$this->description = $rs->getString($startcol + 3);

			$this->author_id = $rs->getInt($startcol + 4);

			$this->mincommitment = $rs->getString($startcol + 5);

			$this->basicsalary = $rs->getString($startcol + 6);

			$this->workfrom = $rs->getString($startcol + 7);

			$this->equity = $rs->getString($startcol + 8);

			$this->posttype = $rs->getString($startcol + 9);

			$this->url = $rs->getString($startcol + 10);

			$this->founders = $rs->getString($startcol + 11);

			$this->founded = $rs->getString($startcol + 12);

			$this->stage = $rs->getString($startcol + 13);

			$this->privatepost = $rs->getBoolean($startcol + 14);

			$this->created_at = $rs->getTimestamp($startcol + 15, null);

			$this->updated_at = $rs->getTimestamp($startcol + 16, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 17; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Posts object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(PostsPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			PostsPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(PostsPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

    if ($this->isModified() && !$this->isColumnModified(PostsPeer::UPDATED_AT))
    {
      $this->setUpdatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(PostsPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aUser !== null) {
				if ($this->aUser->isModified()) {
					$affectedRows += $this->aUser->save($con);
				}
				$this->setUser($this->aUser);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = PostsPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += PostsPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collPost2Twits !== null) {
				foreach($this->collPost2Twits as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collCommentss !== null) {
				foreach($this->collCommentss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTag2Posts !== null) {
				foreach($this->collTag2Posts as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aUser !== null) {
				if (!$this->aUser->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
				}
			}


			if (($retval = PostsPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collPost2Twits !== null) {
					foreach($this->collPost2Twits as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collCommentss !== null) {
					foreach($this->collCommentss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTag2Posts !== null) {
					foreach($this->collTag2Posts as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = PostsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getTitle();
				break;
			case 2:
				return $this->getPosition();
				break;
			case 3:
				return $this->getDescription();
				break;
			case 4:
				return $this->getAuthorId();
				break;
			case 5:
				return $this->getMincommitment();
				break;
			case 6:
				return $this->getBasicsalary();
				break;
			case 7:
				return $this->getWorkfrom();
				break;
			case 8:
				return $this->getEquity();
				break;
			case 9:
				return $this->getPosttype();
				break;
			case 10:
				return $this->getUrl();
				break;
			case 11:
				return $this->getFounders();
				break;
			case 12:
				return $this->getFounded();
				break;
			case 13:
				return $this->getStage();
				break;
			case 14:
				return $this->getPrivatepost();
				break;
			case 15:
				return $this->getCreatedAt();
				break;
			case 16:
				return $this->getUpdatedAt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = PostsPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getTitle(),
			$keys[2] => $this->getPosition(),
			$keys[3] => $this->getDescription(),
			$keys[4] => $this->getAuthorId(),
			$keys[5] => $this->getMincommitment(),
			$keys[6] => $this->getBasicsalary(),
			$keys[7] => $this->getWorkfrom(),
			$keys[8] => $this->getEquity(),
			$keys[9] => $this->getPosttype(),
			$keys[10] => $this->getUrl(),
			$keys[11] => $this->getFounders(),
			$keys[12] => $this->getFounded(),
			$keys[13] => $this->getStage(),
			$keys[14] => $this->getPrivatepost(),
			$keys[15] => $this->getCreatedAt(),
			$keys[16] => $this->getUpdatedAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = PostsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setTitle($value);
				break;
			case 2:
				$this->setPosition($value);
				break;
			case 3:
				$this->setDescription($value);
				break;
			case 4:
				$this->setAuthorId($value);
				break;
			case 5:
				$this->setMincommitment($value);
				break;
			case 6:
				$this->setBasicsalary($value);
				break;
			case 7:
				$this->setWorkfrom($value);
				break;
			case 8:
				$this->setEquity($value);
				break;
			case 9:
				$this->setPosttype($value);
				break;
			case 10:
				$this->setUrl($value);
				break;
			case 11:
				$this->setFounders($value);
				break;
			case 12:
				$this->setFounded($value);
				break;
			case 13:
				$this->setStage($value);
				break;
			case 14:
				$this->setPrivatepost($value);
				break;
			case 15:
				$this->setCreatedAt($value);
				break;
			case 16:
				$this->setUpdatedAt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = PostsPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setAuthorId($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setMincommitment($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setBasicsalary($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setWorkfrom($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setEquity($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setPosttype($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setUrl($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setFounders($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setFounded($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setStage($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setPrivatepost($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setCreatedAt($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setUpdatedAt($arr[$keys[16]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(PostsPeer::DATABASE_NAME);

		if ($this->isColumnModified(PostsPeer::ID)) $criteria->add(PostsPeer::ID, $this->id);
		if ($this->isColumnModified(PostsPeer::TITLE)) $criteria->add(PostsPeer::TITLE, $this->title);
		if ($this->isColumnModified(PostsPeer::POSITION)) $criteria->add(PostsPeer::POSITION, $this->position);
		if ($this->isColumnModified(PostsPeer::DESCRIPTION)) $criteria->add(PostsPeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(PostsPeer::AUTHOR_ID)) $criteria->add(PostsPeer::AUTHOR_ID, $this->author_id);
		if ($this->isColumnModified(PostsPeer::MINCOMMITMENT)) $criteria->add(PostsPeer::MINCOMMITMENT, $this->mincommitment);
		if ($this->isColumnModified(PostsPeer::BASICSALARY)) $criteria->add(PostsPeer::BASICSALARY, $this->basicsalary);
		if ($this->isColumnModified(PostsPeer::WORKFROM)) $criteria->add(PostsPeer::WORKFROM, $this->workfrom);
		if ($this->isColumnModified(PostsPeer::EQUITY)) $criteria->add(PostsPeer::EQUITY, $this->equity);
		if ($this->isColumnModified(PostsPeer::POSTTYPE)) $criteria->add(PostsPeer::POSTTYPE, $this->posttype);
		if ($this->isColumnModified(PostsPeer::URL)) $criteria->add(PostsPeer::URL, $this->url);
		if ($this->isColumnModified(PostsPeer::FOUNDERS)) $criteria->add(PostsPeer::FOUNDERS, $this->founders);
		if ($this->isColumnModified(PostsPeer::FOUNDED)) $criteria->add(PostsPeer::FOUNDED, $this->founded);
		if ($this->isColumnModified(PostsPeer::STAGE)) $criteria->add(PostsPeer::STAGE, $this->stage);
		if ($this->isColumnModified(PostsPeer::PRIVATEPOST)) $criteria->add(PostsPeer::PRIVATEPOST, $this->privatepost);
		if ($this->isColumnModified(PostsPeer::CREATED_AT)) $criteria->add(PostsPeer::CREATED_AT, $this->created_at);
		if ($this->isColumnModified(PostsPeer::UPDATED_AT)) $criteria->add(PostsPeer::UPDATED_AT, $this->updated_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(PostsPeer::DATABASE_NAME);

		$criteria->add(PostsPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setTitle($this->title);

		$copyObj->setPosition($this->position);

		$copyObj->setDescription($this->description);

		$copyObj->setAuthorId($this->author_id);

		$copyObj->setMincommitment($this->mincommitment);

		$copyObj->setBasicsalary($this->basicsalary);

		$copyObj->setWorkfrom($this->workfrom);

		$copyObj->setEquity($this->equity);

		$copyObj->setPosttype($this->posttype);

		$copyObj->setUrl($this->url);

		$copyObj->setFounders($this->founders);

		$copyObj->setFounded($this->founded);

		$copyObj->setStage($this->stage);

		$copyObj->setPrivatepost($this->privatepost);

		$copyObj->setCreatedAt($this->created_at);

		$copyObj->setUpdatedAt($this->updated_at);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getPost2Twits() as $relObj) {
				$copyObj->addPost2Twit($relObj->copy($deepCopy));
			}

			foreach($this->getCommentss() as $relObj) {
				$copyObj->addComments($relObj->copy($deepCopy));
			}

			foreach($this->getTag2Posts() as $relObj) {
				$copyObj->addTag2Post($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new PostsPeer();
		}
		return self::$peer;
	}

	
	public function setUser($v)
	{


		if ($v === null) {
			$this->setAuthorId(NULL);
		} else {
			$this->setAuthorId($v->getId());
		}


		$this->aUser = $v;
	}


	
	public function getUser($con = null)
	{
		if ($this->aUser === null && ($this->author_id !== null)) {
						include_once 'lib/model/om/BaseUserPeer.php';

			$this->aUser = UserPeer::retrieveByPK($this->author_id, $con);

			
		}
		return $this->aUser;
	}

	
	public function initPost2Twits()
	{
		if ($this->collPost2Twits === null) {
			$this->collPost2Twits = array();
		}
	}

	
	public function getPost2Twits($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BasePost2TwitPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collPost2Twits === null) {
			if ($this->isNew()) {
			   $this->collPost2Twits = array();
			} else {

				$criteria->add(Post2TwitPeer::POST_ID, $this->getId());

				Post2TwitPeer::addSelectColumns($criteria);
				$this->collPost2Twits = Post2TwitPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(Post2TwitPeer::POST_ID, $this->getId());

				Post2TwitPeer::addSelectColumns($criteria);
				if (!isset($this->lastPost2TwitCriteria) || !$this->lastPost2TwitCriteria->equals($criteria)) {
					$this->collPost2Twits = Post2TwitPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastPost2TwitCriteria = $criteria;
		return $this->collPost2Twits;
	}

	
	public function countPost2Twits($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BasePost2TwitPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(Post2TwitPeer::POST_ID, $this->getId());

		return Post2TwitPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addPost2Twit(Post2Twit $l)
	{
		$this->collPost2Twits[] = $l;
		$l->setPosts($this);
	}

	
	public function initCommentss()
	{
		if ($this->collCommentss === null) {
			$this->collCommentss = array();
		}
	}

	
	public function getCommentss($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseCommentsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collCommentss === null) {
			if ($this->isNew()) {
			   $this->collCommentss = array();
			} else {

				$criteria->add(CommentsPeer::POST_ID, $this->getId());

				CommentsPeer::addSelectColumns($criteria);
				$this->collCommentss = CommentsPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(CommentsPeer::POST_ID, $this->getId());

				CommentsPeer::addSelectColumns($criteria);
				if (!isset($this->lastCommentsCriteria) || !$this->lastCommentsCriteria->equals($criteria)) {
					$this->collCommentss = CommentsPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastCommentsCriteria = $criteria;
		return $this->collCommentss;
	}

	
	public function countCommentss($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseCommentsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(CommentsPeer::POST_ID, $this->getId());

		return CommentsPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addComments(Comments $l)
	{
		$this->collCommentss[] = $l;
		$l->setPosts($this);
	}


	
	public function getCommentssJoinUser($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseCommentsPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collCommentss === null) {
			if ($this->isNew()) {
				$this->collCommentss = array();
			} else {

				$criteria->add(CommentsPeer::POST_ID, $this->getId());

				$this->collCommentss = CommentsPeer::doSelectJoinUser($criteria, $con);
			}
		} else {
									
			$criteria->add(CommentsPeer::POST_ID, $this->getId());

			if (!isset($this->lastCommentsCriteria) || !$this->lastCommentsCriteria->equals($criteria)) {
				$this->collCommentss = CommentsPeer::doSelectJoinUser($criteria, $con);
			}
		}
		$this->lastCommentsCriteria = $criteria;

		return $this->collCommentss;
	}

	
	public function initTag2Posts()
	{
		if ($this->collTag2Posts === null) {
			$this->collTag2Posts = array();
		}
	}

	
	public function getTag2Posts($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseTag2PostPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTag2Posts === null) {
			if ($this->isNew()) {
			   $this->collTag2Posts = array();
			} else {

				$criteria->add(Tag2PostPeer::POST_ID, $this->getId());

				Tag2PostPeer::addSelectColumns($criteria);
				$this->collTag2Posts = Tag2PostPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(Tag2PostPeer::POST_ID, $this->getId());

				Tag2PostPeer::addSelectColumns($criteria);
				if (!isset($this->lastTag2PostCriteria) || !$this->lastTag2PostCriteria->equals($criteria)) {
					$this->collTag2Posts = Tag2PostPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTag2PostCriteria = $criteria;
		return $this->collTag2Posts;
	}

	
	public function countTag2Posts($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseTag2PostPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(Tag2PostPeer::POST_ID, $this->getId());

		return Tag2PostPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addTag2Post(Tag2Post $l)
	{
		$this->collTag2Posts[] = $l;
		$l->setPosts($this);
	}


	
	public function getTag2PostsJoinTags($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseTag2PostPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTag2Posts === null) {
			if ($this->isNew()) {
				$this->collTag2Posts = array();
			} else {

				$criteria->add(Tag2PostPeer::POST_ID, $this->getId());

				$this->collTag2Posts = Tag2PostPeer::doSelectJoinTags($criteria, $con);
			}
		} else {
									
			$criteria->add(Tag2PostPeer::POST_ID, $this->getId());

			if (!isset($this->lastTag2PostCriteria) || !$this->lastTag2PostCriteria->equals($criteria)) {
				$this->collTag2Posts = Tag2PostPeer::doSelectJoinTags($criteria, $con);
			}
		}
		$this->lastTag2PostCriteria = $criteria;

		return $this->collTag2Posts;
	}

} 